<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<!DOCTYPE HTML>
<html>
	<head>
		<base href="${pageContext.request.contextPath}/">
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>修改密码</title>
        <link rel="shortcut icon" href="favicon.ico">
        <link href="resource/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
        <link href="resource/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
        <link href="resource/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
        <link href="resource/admin/css/animate.css" rel="stylesheet">
        <link href="resource/admin/css/style.css?v=4.1.0" rel="stylesheet">
    </head>
    <body class="gray-bg">
        <div class="wrapper wrapper-content">
                <!-- 定义行数 -->
                <div class="row">
                    <!-- 定义列数 -->
                    <div class="col-md-12">
                        <div class="ibox float-e-margins">
                            <!-- 定义标题 -->
                            <div class="ibox-title">
                                <h5>个人修改密码</h5>
                            </div>
                            <!-- 定义内容 -->
                            <div class="ibox-content">
                                <form method="post" class="form-horizontal" action="sys/user/password" id="userForm">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">原密码</label>
                                        <div class="col-sm-4">
                                            <input type="password" name="old_password" id="old_password" class="form-control">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">新密码</label>
                                        <div class="col-sm-4">
                                            <input type="password" name="password" id="password" class="form-control">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">确认密码</label>
                                        <div class="col-sm-4">
                                            <input type="password" name="new_password" id="new_password" class="form-control">
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>
                                    <div class="form-group">
                                        <div class="col-sm-4 col-sm-offset-2">
                                            <button class="btn btn-primary" type="submit">修改密码</button>
                                            <button class="btn btn-default" type="reset">取消</button>
                                            <button class="btn btn-white" type="button" onclick="javascript:history.back()">返回</button>
                                        </div>
                                    </div>
                                    <%--隐藏域 --%>
                                    <input type="hidden" name="_method" value="patch">
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
        </div>

        <!-- 全局js -->
        <script src="resource/admin/js/jquery.min.js?v=2.1.4"></script>
        <script src="resource/admin/js/bootstrap.min.js?v=3.3.6"></script>

        <!-- 自定义js -->
        <script src="resource/admin/js/content.js?v=1.0.0"></script>
        
        <!-- 引入jquery的插件验证框架 -->
        <script src="resource/admin/js/plugins/validate/jquery.validate.min.js"></script>
        <script src="resource/admin/js/plugins/validate/messages_zh.min.js"></script>
        <!-- 错误提示的自定义样式 -->
        <script src="resource/admin/js/plugins/validate/validation.js"></script>
        
        <!-- iCheck -->
        <script src="resource/admin/js/plugins/iCheck/icheck.min.js"></script>
        <script>
            $(document).ready(function () {
                $('.i-checks').iCheck({
                    checkboxClass: 'icheckbox_square-green',
                    radioClass: 'iradio_square-green',
                });
            });
        </script>
        <script type="text/javascript">
        $(function(){
            var icon = "<i class='fa fa-times-circle'></i> ";
            $("#userForm").validate({
                rules:{
                    old_password:{
                        required:true,
                        rangelength:[3,16],
                        remote:{
                            url:"sys/user/valid/password",
                            type:"get",
                            data:{//要传递的数据
                                password: function() {
                                    return $("#old_password").val();
                                }
                            },
                            //dataType:"json",//JSON字符串转换为JavaScript对象,就是处理data参数
                            dataFilter:function(data){//data接收服务端返回的数据 true或者false
                                data = JSON.parse(data);
                                return data.flag;
                                //return true或者false
                            }
                        }
                    },
                    password:{
                    	required:true,
                    	rangelength:[3,16]
                    },
                    new_password:{
                    	required:true,
                        rangelength:[3,16],
                        equalTo:"#password"
                    }
                },
                messages:{
                	old_password:{
                        required:icon+"请输入原密码",
                        rangelength:icon+"您输入的密码的长度应该在3到16位之间",
                        remote:icon+"您输入的原密码错误！"
                    },
                    password:{
                    	required:icon+"请输入新密码",
                        rangelength:icon+"您输入的密码的长度应该在3到16位之间"
                    },
                    new_password:{
                    	required:icon+"请输入确认密码",
                        rangelength:icon+"您输入的密码的长度应该在3到16位之间",
                        equalTo:icon+"输入的确认密码跟新密码不一致！"
                    }
                },
                onfocusout:false,
                onkeyup:false
            });
        });
        </script>
    </body>
</html>